--[[
Copyright:www.vxinyou.com
Author:Hongru
CreateTime:2014-12-06
Description:读取音乐音效配置(单例)
--]]

local clsAudioCfg = Class("lua/util/clsInstance.lua"):Inherit()

------------------------------public------------------------------
------------------------------------------------------------------

local config = Import("lua/config/audios.lua").getData()

local audioType = {
	"audioNone", -- 1
	"audioBackground", -- 2
	"audioEffect", -- 3
	"audioUI", -- 4
}

function clsAudioCfg:getAudioConfig()
	return config
end

function clsAudioCfg:getAudioNameByID(ID)
	assert(config[ID])
	if config[ID] then
		return config[ID]["name"]
	end
end

function clsAudioCfg:getAudiodescriptByID(ID)
	assert(config[ID])
	if config[ID] then
		return config[ID]["descript"]
	end
end

function clsAudioCfg:getAudioFileNameByID(ID)
	assert(config[ID])
	assert(config[ID]["file_name"],"No file_name")
	return config[ID]["file_name"]
end

--Caution:配置表里的type从0开始，因此加1以对应lua的下标
function clsAudioCfg:getAudioTypeByID(ID)
	assert(config[ID])
	if config[ID]["type"] then
		return audioType[config[ID]["type"] + 1]
	end
end

function clsAudioCfg:getAudioIsLoopByID(ID)
	assert(config[ID])
	if config[ID] then
		if config[ID]["is_loop"] == 1 then
			return true
		elseif config[ID]["is_loop"] == 0 then
			return false
		end
	end
end

function clsAudioCfg:getAudioVolumeByID(ID)
	assert(config[ID])
	if config[ID] then
		return config[ID]["volume"] or 1
	end
end

function getClass()
	return clsAudioCfg
end

------------------------------private-----------------------------
------------------------------------------------------------------

function clsAudioCfg:New(...)
	return self
end


